﻿using Krypton;
using Krypton.Lights;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DefCore.Tools
{
    public static class LightFactory
    {
        public static Texture2D LightTexture;

        public static Light2D CreateLight(int range, Color lightColor)
        {
            return CreateLight(range, lightColor, 1f, MathHelper.TwoPi);
        }
        public static Light2D CreateLight(int range, Color lightColor, float intensity)
        {
            return CreateLight(range, lightColor, intensity, MathHelper.TwoPi);
        }
        public static Light2D CreateLight(int range, Color lightColor, float intensity, float fov)
        {
            if (LightTexture == null)
            {
                LightFactory.LightTexture = LightTextureBuilder.CreatePointLight(Objects.GameObject.GraphicsDevice, 512);
                //throw new Exception("ERROR: LightTexture has not been set prior to call too CreateLight(...)");
            }

            var light = new Light2D()
            {
                Texture = LightFactory.LightTexture,
                Range = range,
                Color = lightColor,
                Intensity = intensity,
                Fov = fov,
            };

            light.ShadowType = ShadowType.Solid;
            //LightTexture = null;
            return light;
        }
    }
}
